//
//  CarCollectionCell.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 2017/5/16.
//  Copyright © 2017年 EasyToTesco. All rights reserved.
//

#import "CarCollectionCell.h"

@interface  CarCollectionCell()

//@property(nonatomic,strong)UIImageView *contentImg;
//@property(nonatomic,strong)UILabel     *nameLabel;
@property(nonatomic,strong)UIView      *alphaView;


@end

@implementation CarCollectionCell


- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self buildSubViews];
    }
    return self;
}

- (void)buildSubViews
{
    [self.contentView addSubview:self.contentImg];
    [self.contentView addSubview:self.alphaView];
    [self.contentView addSubview:self.nameLabel];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    
    self.contentImg.frame = CGRectMake(0,0,self.width, self.Height);
    WeakSelf(self);
    [self.alphaView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakself);
        make.right.equalTo(weakself);
        make.bottom.equalTo(weakself);
        make.height.mas_equalTo(25);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(weakself.alphaView);
    }];

}


#pragma mark lazy
- (UIView *)alphaView
{
    if (!_alphaView) {
        _alphaView = [[UIView alloc] init];
        _alphaView.backgroundColor = [UIColor blackColor];
        _alphaView.alpha = 0.2f;
    }
    return _alphaView;
}

- (UIImageView *)contentImg
{
    if (!_contentImg) {
        _contentImg = [[UIImageView alloc] init];
    }
    return _contentImg;
}

- (UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = [UIColor whiteColor];
        _nameLabel.font = FONT(12);
        _nameLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _nameLabel;
}

@end
